import { HttpMethod } from '@/services/types';
import { request } from '@/api/request';

/**
 * POST /orders/alipay 获取支付二维码
 * @param params
 * @param options
 */
export async function resAlipay(
  params: API.AlipayParams,
  options?: { [key: string]: any },
) {
  return request<string>('/orders/alipay', {
    method: HttpMethod.POST,
    data: params,
    ...(options || {}),
  });
}

/**
 * GET /orders/status/:id 查询支付状态
 * @param id
 * @param options
 */
export async function resAlipayStatus(
  id:string,
  options?: { [key: string]: any },
) {
  return request<API.QueryStatusResult>('/orders/status/'+id, {
    method: HttpMethod.GET,
    ...(options || {}),
  });
}

/**
 * GET /orders/refund_query/:id 退款查询
 * @param id
 * @param options
 */
export async function resQueryRefund(
  id:number,
  options?: { [key: string]: any },
) {
  return request<R<API.QueryRefundResult>>('/orders/refund_query/'+id, {
    method: HttpMethod.GET,
    ...(options || {}),
  });
}

/**
 * GET /orders/alipay_notify 支付成功后的跳转路径
 * @param params
 * @param options
 */
export async function resAlipayReturn(
  params: string,
  options?: { [key: string]: any },
) {
  return request<API.OrdersDetailResult[]>('/orders/alipay_notify?'+params, {
    method: HttpMethod.GET,
    ...(options || {}),
  });
}

/**
 * POST  /orders/refund/:id 退款
 * @param id
 * @param options
 */
export async function resRefund(
  id:number,
  options?: { [key: string]: any },
) {
  return request<R<API.AddressStruct>>('/orders/refund/'+id, {
    method: HttpMethod.POST,
    ...(options || {}),
  });
}




